package com.xls.box2023.jifen;


import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.lzz.bottomencapsulation.consts.EventbusCode;
import com.lzz.bottomencapsulation.eventbus.MessageEvent;
import com.lzz.bottomencapsulation.statusbar.StatusBarHeightView;
import com.xls.box2023.R;
import com.xls.box2023.mvp.MVPBaseActivity;
import com.xls.xrecyclerview.XRecyclerView;

import androidx.recyclerview.widget.LinearLayoutManager;


/**
 * MVPPlugin
 */

public class JiFenActivity extends MVPBaseActivity<JiFenContract.View, JiFenPresenter> implements JiFenContract.View, View.OnClickListener {

    private TextView title_text;
    private TextView title_back;
    private StatusBarHeightView title_rl_content;
    private TextView jifen_yue_title;
    private TextView jifen_yue;
    private TextView jifen_unit;
    private XRecyclerView jifen_list;

    public static void startActivity(Activity activity) {
        Intent intent=new Intent(activity,JiFenActivity.class);
        activity.startActivity(intent);
    }

    @Override
    public int getView() {
        return R.layout.activity_jifen;
    }

    @Override
    public void initView() {

        title_text = findViewById(R.id.title_text);
        title_back = findViewById(R.id.title_back);
        title_rl_content = findViewById(R.id.title_rl_content);
        jifen_yue_title = findViewById(R.id.jifen_yue_title);
        jifen_yue = findViewById(R.id.jifen_yue);
        jifen_unit = findViewById(R.id.jifen_unit);
        title_back.setOnClickListener(this);
        jifen_list = findViewById(R.id.jifen_list);
        title_text.setText("收益明细");

        setAdapter();
    }

    private void setAdapter() {
        jifen_list.setLayoutManager(new LinearLayoutManager(this));
        jifen_list.setAdapter(mPresenter.getJiFenMingXiAdapter());
        jifen_list.setLoadingMoreEnabled(false);
        jifen_list.setPullRefreshEnabled(false);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.title_back) {
            finish();
        }
    }

    @Override
    public void showNum(String score) {
        jifen_yue.setText(score+"");
    }

    @Override
    public void onEvent(MessageEvent messageEvent) {
        super.onEvent(messageEvent);
        if (messageEvent.getCode()== EventbusCode.CODE_TIXIAN_OK){
            mPresenter.getSourceData();
        }
    }
}
